<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/salesReport.do?action=salesreport" />
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%@ page import="java.util.Calendar" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.GregorianCalendar" %>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext(); %> 
<%
    String userTypeChiptrac     = Constants.USER_TYPE_CHIPTRAC + "";
%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<!-- Added by Krishna Prasad on 10 May 2004, to get From and To Date Validation function -->
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></SCRIPT>

<script>
var dateElement = "";
    function openCalendar(dateValue)
    {
	dateElement = dateValue;
  	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
  	newWindow.moveTo(550,180);
  	newWindow.focus();
    }
	function assignDate(passedValue)
    {
	dateElement.value=passedValue;
	window.focus();
    }

	function Disab()
    {
	    len=document.salesReport.category.length
	    for(var i=0; i<len; i++)
        {
            if(document.salesReport.category[i].checked)
		    {
			    var temp = document.salesReport.category[i].value;

    			if(temp == 'shippednotinvoiced')
                {
				    for(var j = 0; j<document.salesReport.periodically.length; j++)
                    {
					    document.salesReport.periodically[j].disabled = true;
				    }
			    }
		    }

        }
    }

function enablePeriod(){

    var sort_order = "";
    for (counter = 0; counter < salesReport.orderBy.length; counter++)
    {
        if (salesReport.orderBy[counter].checked){

	        sort_order = salesReport.orderBy[counter].value;
        }
	}

	for(var j = 0; j<document.salesReport.periodically.length; j++){

        if( sort_order == 'salesOrder')
        {
		    document.salesReport.periodically[j].disabled = true;
        }
        else
        {
            document.salesReport.periodically[j].disabled = false;
        }
	}
}

function enableSort()
{
    var cat = "";
    for (counter = 0; counter < salesReport.category.length; counter++)
    {
        if (salesReport.category[counter].checked){
	        cat = salesReport.category[counter].value;
	    }
    }

    for (counter = 0; counter < salesReport.orderBy.length; counter++)
    {
        if( cat == 'bookingReport')
        {
		    document.salesReport.orderBy[counter].disabled = false;
        }
        else
        {
   		    document.salesReport.orderBy[counter].disabled = true;
        }
	}

    var sort_order = "";

    for (counter = 0; counter < salesReport.orderBy.length; counter++)
    {
        if (salesReport.orderBy[counter].checked){

	        sort_order = salesReport.orderBy[counter].value;
        }
	}

    for(var j = 0; j<document.salesReport.periodically.length; j++){

        if( cat == 'bookingReport' && sort_order == 'salesOrder')
        {
		    document.salesReport.periodically[j].disabled = true;
        }
        else
        {
   		    document.salesReport.periodically[j].disabled = false;
        }
	}

}

<%-- Added by Krishna Prasad on 10 May 2004 for Validating the 'To' and 'From' Dates --%>
function validateFromAndToDates()
{
    formdoc = document.salesReport;
    errMsg = '';

    var pa	= document.getElementById("errors")

    if(chkDate(formdoc.fromdate.value,'From-Date','N') == false)
    {
        pa.innerHTML = errMsg;
        formdoc.fromdate.focus();
        return false;
    }

    if(chkDate(formdoc.todate.value,'To-Date','N') == false)
    {
        pa.innerHTML = errMsg;
        formdoc.todate.focus();
        return false;
    }

    //alert("chk Date " + validateDateOut(formatDateAsMMDDYYYY(formdoc.datefrom.value),formatDateAsMMDDYYYY(formdoc.todate.value)));

    if(formdoc.fromdate.value!='' && formdoc.todate.value!='')
    {
        if (!validateDateOut(formatDateAsMMDDYYYY(formdoc.fromdate.value),formatDateAsMMDDYYYY(formdoc.todate.value)))
        {
            pa.innerHTML = "To Date cannot be less than From Date";
            formdoc.todate.focus();
            return false;
        }
    }

    //pa.innerHTML = errMsg;
    return true;
}
<%-- ends Added by Krishna Prasad on 10 May 2004  --%>

function dateRange( fileType ){

var period="";
var cat="";
var sort_order="";
var pa	= document.getElementById("errors")
    
var d = new Date();
		var day = d.getDate();
		var month = d.getMonth()+1;
		var year = d.getFullYear();
		var hour = d.getHours();
		var min = d.getMinutes();
		var sec = d.getSeconds();

		var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;

        //Added by Krishna Prasad on 10 May 2004,for calling validateFromAndToDates function which Validating the 'To' and 'From' Dates
        var success;
        success = true;
		success = validateFromAndToDates();
		if(success == false)
        {
           return false;
        }   //ends Added by Krishna Prasad on 10 May 2004

for (counter = 0; counter < salesReport.category.length; counter++)
{
if (salesReport.category[counter].checked){
	cat = salesReport.category[counter].value;
	}
}

for (counter = 0; counter < salesReport.periodically.length; counter++)
{
if (salesReport.periodically[counter].checked){
	period = salesReport.periodically[counter].value;
	}
}

for (counter = 0; counter < salesReport.orderBy.length; counter++)
{
if (salesReport.orderBy[counter].checked){
	sort_order = salesReport.orderBy[counter].value;
	}
}

var partNumberObj = document.salesReport.products;
var processstepId = "";
var count = 0;
for( var i = 0; i < partNumberObj.length; i++ )
{
    if( partNumberObj.options[i].selected )
    {
        count++;
        if ( processstepId != '' )
        {
            processstepId = processstepId + "," + partNumberObj.options[i].value;
        }
        else
        {
            processstepId = partNumberObj.options[i].value;
            if( partNumberObj.options[i].value == '0' )
            {
                break;
            }
        }
    }
}
if ( processstepId == '')
{
    processstepId = "0";
}
if( count > 10)
{
    pa.innerHTML = "<li>Please select upto 10 Products only";
    return false;
}
else
{
    document.salesReport.prompt3.value = processstepId;
}

if (document.salesReport.fromdate.value == '')
	document.salesReport.prompt0.value = '0';
else
	document.salesReport.prompt0.value = document.salesReport.fromdate.value;

if (document.salesReport.todate.value == '')
	document.salesReport.prompt1.value = '0';
else
	document.salesReport.prompt1.value = document.salesReport.todate.value;

if (document.salesReport.customers.value == '')
	document.salesReport.prompt2.value = '0';
else
	document.salesReport.prompt2.value = document.salesReport.customers.value;

<logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
if  ( document.salesReport.prompt2.value== 0 )
{
    var element = document.salesReport.customers;
    var customerIds = "";
    for( var i = 0 ; i < element.length; i++ )
    {
        if ( customerIds != '' && customerIds != "0" )
        {
            customerIds = customerIds+","+element.options[i].value;
        }
        else
        {
            customerIds = element.options[i].value;
        }
    }

    document.salesReport.prompt2.value= customerIds;
}
</logic:notEqual>
/*if (document.salesReport.products.value == '')
	document.salesReport.prompt3.value = '0';
else
	document.salesReport.prompt3.value = document.salesReport.products.value;*/
if (document.salesReport.region.value == '')
	document.salesReport.prompt4.value = '0';
else
	document.salesReport.prompt4.value = document.salesReport.region.value;
if (document.salesReport.repoffices.value == '')
	document.salesReport.prompt5.value = '0';
else
	document.salesReport.prompt5.value = document.salesReport.repoffices.value;

if (document.salesReport.endCustomer.value == '')
	document.salesReport.prompt6.value = '0';
else
	document.salesReport.prompt6.value = document.salesReport.endCustomer.value;
<logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
if  ( document.salesReport.prompt6.value== 0 )
{
    var element = document.salesReport.enduser;
    var customerIds = "";
    for( var i = 0 ; i < element.length; i++ )
    {
        if ( customerIds != '' && customerIds != "0" )
        {
            customerIds = customerIds+","+element.options[i].value;
        }
        else
        {
            customerIds = element.options[i].value;
        }
    }

    document.salesReport.prompt6.value= customerIds;
}
</logic:notEqual>
if (document.salesReport.sperson.value == '')
	document.salesReport.prompt7.value = '0';
else
	document.salesReport.prompt7.value = document.salesReport.sperson.value;
<logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
if  ( document.salesReport.prompt7.value== 0 )
{
    var element = document.salesReport.sperson;
    var customerIds = "";
    for( var i = 0 ; i < element.length; i++ )
    {
        if ( customerIds != '' && customerIds != "0" )
        {
            customerIds = customerIds+","+element.options[i].value;
        }
        else
        {
            customerIds = element.options[i].value;
        }
    }

	if (customerIds == '')
	{
		document.salesReport.prompt7.value ='0'; 
	}
	else
	{
		document.salesReport.prompt7.value= customerIds;
	}
    //document.salesReport.prompt7.value= customerIds;
}
</logic:notEqual>
document.salesReport.prompt8.value = defaultPrompt;
//document.salesReport.prompt8.value = sort_order;

//alert( " cat="+ cat +'][sort_order=' + sort_order +'');
if ( cat == "bookingReport" && sort_order == "bookingDate")
{
    document.salesReport.prompt9.value = 'BOOKING';
}
else
{
    document.salesReport.prompt9.value = sort_order;
}
document.salesReport.prompt10.value = document.salesReport.orderType.value;

if (document.salesReport.endUser.value == '')
	document.salesReport.prompt11.value = '0';
else
	document.salesReport.prompt11.value = document.salesReport.endUser.value;
<logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
if  ( document.salesReport.prompt11.value== 0 )
{
    var element = document.salesReport.endUser;
    var customerIds = "";
    for( var i = 0 ; i < element.length; i++ )
    {
        if ( customerIds != '' && customerIds != "0" )
        {
            customerIds = customerIds+","+element.options[i].value;
        }
        else
        {
            customerIds = element.options[i].value;
        }
    }

    document.salesReport.prompt11.value= customerIds;
}
</logic:notEqual>
    document.salesReport.prompt12.value = period;
    document.salesReport.prompt13.value = "Crystal";

  if ( cat == "bookingReport" && sort_order == "salesOrder")
  {
      document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/Booking_Report_by_SalesOrder.rpt";
  }
  else if ( cat == "bookingReport" )
  {
       document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/Booking_Report.rpt";
  }
  else if ( cat == "cancellation" )
  {
      document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/Cancellation_Report.rpt";
  }
  else if ( cat == "hold" )
  {
      document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/Hold_Report.rpt";
  }
  else if ( cat == "delinquent" )
  {
      document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/Deliquent_Report.rpt";
  }

 <%--   if ( cat == "bookingReport" && sort_order == "salesOrder"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_bookingrpt_salesOrder.rpt";
		//document.salesReport.submit();
	}

	//else if ( cat == "bookingReport" && period=="byWeek" /*&& sort_order == "changeDate"*/){
		//document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_bookingrpt_week.rpt";
        else if ( cat == "bookingReport" && period =="byWeek" )
        {
            if ( cat == "bookingReport" && sort_order == "bookingDate")
            {
                document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_bookingdate_rpt_week.rpt";
            }
            else
            {
                document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_bookingrpt_week.rpt";
            }
            //document.salesReport.submit();
        }

	//else if ( cat == "bookingReport" && period=="byMonth" /*&& sort_order == "changeDate"*/){
      else if ( cat == "bookingReport" && period =="byMonth" ){
       if( cat == "bookingReport" && sort_order == "bookingDate")
       {
            document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_bookingrpt_month.rpt";
       }
       else
       {
            document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_change_rpt_month.rpt";
       }
		//document.salesReport.submit();
	}

	//else if ( cat == "bookingReport" && period=="byQuarter" /*&& sort_order == "changeDate"*/){
        //document.salesReport.prompt9.value = '0';
        else if ( cat == "bookingReport" && period =="byQuarter" ){
        if( cat == "bookingReport" && sort_order == "bookingDate")
       {
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_bookingrpt_quarter.rpt";
       }
       else
       {
        document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_change_rpt_quarter.rpt";
       }
		//document.salesReport.submit();
	}

	else if ( cat == "cancellation" && period=="byWeek"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_cancellation_week.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "cancellation" && period=="byMonth"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_cancellation_month.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "cancellation" && period=="byQuarter"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_cancellation_quarter.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "pending" && period=="byWeek"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_pending_week.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "pending" && period=="byMonth"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_pending_month.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "pending" && period=="byQuarter"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_pending_quarter.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "hold" && period=="byWeek"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_Holdreport_week.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "hold" && period=="byMonth"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_Holdreport_month.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "hold" && period=="byQuarter"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALE_Holdreport_quarter.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "changed" && period=="byWeek"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALES_report_changed_week.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "changed" && period=="byMonth"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALES_report_changed_month.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "changed" && period=="byQuarter"){
	document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/SALES_report_changed_quarter.rpt";
		//document.salesReport.submit();
	}

	--%><%--else if ( cat == "samples" && period=="byWeek"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/Samples/SALES_report_Samples_week.rpt";
		//document.salesReport.submit();
	}

	else if ( cat == "samples" && period=="byMonth"){
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/Samples/SALES_report_Samples_month.rpt";
		document.salesReport.submit();
	}

	else if ( cat == "samples" && period=="byQuarter"){
	document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Sales_Orders/Samples/SALES_report_Samples_quarter.rpt";
		//document.salesReport.submit();
	}

	else if (cat == 'shippednotinvoiced') {
			document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Backlog/Customer_Order_Shipped_Not_Invoiced.rpt";
			//document.salesReport.submit();
	}--%><%--
	else if (cat == 'delinquent' && period=="byMonth") {
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Missed_Orders/SALE_missed_booking_month.rpt";
			//document.salesReport.submit();
	}
	else if (cat == 'delinquent' && period=="byQuarter") {
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Missed_Orders/SALE_missed_booking_quarter.rpt";
			//document.salesReport.submit();
	}
	else if (cat == 'delinquent' && period=="byWeek") {
		document.salesReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Missed_Orders/SALE_missed_booking_week.rpt";
			//document.salesReport.submit();
	}--%>

    if( fileType == 2 )
    {    
        var prompt0 = document.salesReport.prompt0.value;
        var prompt1 = document.salesReport.prompt1.value;
        var prompt2 = document.salesReport.prompt2.value;
        var prompt3 = document.salesReport.prompt3.value;
        var prompt4 = document.salesReport.prompt4.value;
        var prompt5 = document.salesReport.prompt5.value;
        var prompt6 = document.salesReport.prompt6.value;
        var prompt7 = document.salesReport.prompt7.value;
        var prompt8 = document.salesReport.prompt8.value;
        var prompt9 = document.salesReport.prompt9.value;
        var prompt10 = document.salesReport.prompt10.value;
        var prompt11 = document.salesReport.prompt11.value;
        var prompt12 = period;
        var prompt13 = 'XLREPORT';

        var newWindow;

        if ( cat == "bookingReport" )
        {
            var url = '<%=chipTracContext%>/customerReport.do?action=bookingxls&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 + '&prompt9=' + prompt9 + '&prompt10=' + prompt10 + '&prompt11=' + prompt11 + '&prompt12=' + prompt12 + '&prompt13=' + prompt13;
            newWindow = window.open ( url, 'SalesBookingReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
        else if ( cat == "cancellation" )
        {
            var url = '<%=chipTracContext%>/customerReport.do?action=cancelxls&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 + '&prompt9=' + prompt9 + '&prompt10=' + prompt10 + '&prompt11=' + prompt11 + '&prompt12=' + prompt12 + '&prompt13=' + prompt13;
            newWindow = window.open ( url, 'SalesCancellationReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
        else if ( cat == "hold" )
        {
            var url = '<%=chipTracContext%>/customerReport.do?action=holdxls&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 + '&prompt9=' + prompt9 + '&prompt10=' + prompt10 + '&prompt11=' + prompt11 + '&prompt12=' + prompt12 + '&prompt13=' + prompt13;
            newWindow = window.open ( url, 'SalesHoldReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
        else if ( cat == "delinquent" )
        {
            var url = '<%=chipTracContext%>/customerReport.do?action=delinquentxls&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 + '&prompt9=' + prompt9 + '&prompt10=' + prompt10 + '&prompt11=' + prompt11 + '&prompt12=' + prompt12 + '&prompt13=' + prompt13;
            newWindow = window.open ( url, 'SalesDeliquentReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
    }
    else if( fileType == 3 )
    {
        var prompt0 = document.salesReport.prompt0.value;
        var prompt1 = document.salesReport.prompt1.value;
        var prompt2 = document.salesReport.prompt2.value;
        var prompt3 = document.salesReport.prompt3.value;
        var prompt4 = document.salesReport.prompt4.value;
        var prompt5 = document.salesReport.prompt5.value;
        var prompt6 = document.salesReport.prompt6.value;
        var prompt7 = document.salesReport.prompt7.value;
        var prompt8 = document.salesReport.prompt8.value;
        var prompt9 = document.salesReport.prompt9.value;
        var prompt10 = document.salesReport.prompt10.value;
        var prompt11 = document.salesReport.prompt11.value;
        var prompt12 = period;
        var prompt13 = 'XLREPORT';

        var newWindow;

        if ( cat == "bookingReport" )
        {
            var url = '<%=chipTracContext%>/customerReport.do?action=bookingcsv&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 + '&prompt9=' + prompt9 + '&prompt10=' + prompt10 + '&prompt11=' + prompt11 + '&prompt12=' + prompt12 + '&prompt13=' + prompt13;
            newWindow = window.open ( url, 'SalesBookingReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
        else if ( cat == "cancellation" )
        {
            var url = '<%=chipTracContext%>/customerReport.do?action=cancelcsv&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 + '&prompt9=' + prompt9 + '&prompt10=' + prompt10 + '&prompt11=' + prompt11 + '&prompt12=' + prompt12 + '&prompt13=' + prompt13;
            newWindow = window.open ( url, 'SalesCancellationReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
        else if ( cat == "hold" )
        {
            var url = '<%=chipTracContext%>/customerReport.do?action=holdcsv&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 + '&prompt9=' + prompt9 + '&prompt10=' + prompt10 + '&prompt11=' + prompt11 + '&prompt12=' + prompt12 + '&prompt13=' + prompt13;
            newWindow = window.open ( url, 'SalesHoldReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
        else if ( cat == "delinquent" )
        {
            var url = '<%=chipTracContext%>/customerReport.do?action=delinquentcsv&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 + '&prompt9=' + prompt9 + '&prompt10=' + prompt10 + '&prompt11=' + prompt11 + '&prompt12=' + prompt12 + '&prompt13=' + prompt13;
            newWindow = window.open ( url, 'SalesDeliquentReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
    }
    else
    {
        document.salesReport.submit();
        return true;
    }
}

function installNPViewer()
{
    //D:\chiptrac_spectra\jsp\includes\npviewer.exe
    var url = '<%=chipTracContext%>/jsp/includes/others/npviewer.exe';
                newWindow = window.open ( url, 'InstallNPViewer', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=50,height=50,resizable=no');
}
function initLoad(){
    <%!
      String fromDate = null;
      String toDate = null;
    %>
    <%

        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
        Calendar calendar = Calendar.getInstance();
        GregorianCalendar gc = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE));
        gc.add(GregorianCalendar.YEAR, -1);
        Date d = gc.getTime();
        fromDate = sdf.format(d);

        SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy");
        Calendar calendar1 = Calendar.getInstance();
        GregorianCalendar gc1 = new GregorianCalendar(calendar1.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE));
        gc1.add(GregorianCalendar.DATE, 1);
        Date d1 = gc1.getTime();
        toDate = sdf1.format(d1);
    %>
    document.getElementById("fromdate").value = "<%=fromDate%>";
    document.getElementById("todate").value = "<%=toDate%>";
}

</script>


<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="initLoad();">

<form name=salesReport method="post">
<input type="hidden" name="prompt0">
<input type="hidden" name="prompt1">
<input type="hidden" name="prompt2">
<input type="hidden" name="prompt3">
<input type="hidden" name="prompt4">
<input type="hidden" name="prompt5">
<input type="hidden" name="prompt6">
<input type="hidden" name="prompt7">
<input type="hidden" name="prompt8">
<input type="hidden" name="prompt9">
<input type="hidden" name="prompt10">
<input type="hidden" name="prompt11">
<input type="hidden" name="prompt12">
<input type="hidden" name="prompt13">

<!-- Top Header Start-->
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
<!-- Side Navigation start -->
<%--<%@ include file="/jsp/sales/sales_report_menu.jsp" %>--%>
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/sales/sales_report_menu.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/sales/external_reports_menu.jsp" %>
    </logic:notEqual>
<!-- end of the side navigations -->
<TD bgcolor="#ffffff">
<IMG height=9 src="images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->

<center><span class="NArialW">Booking Reports&nbsp;&nbsp;&nbsp;&nbsp;</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
  <table border="0" width="90%" align=right cellspacing="4" cellpadding="2">
    <tr><td colspan=6 align="left" class='NArialL'><b><font face="Verdana" size="-5" align="center" color="#ff0000" id="errors"></font></b></td></tr>
    <tr><td colsapn=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
        <td width="5%" valign= "top">&nbsp;</td>
        <td width="20%" valign= "top"><font class="NArialL" >Customer :</font></td>
        <td width="20%" valign= "top" class="NArialL" >
            <select name="customers" class="txfield" style= "width:170px">
                    <logic:iterate id="customerSelectList" name="customerSelectList">
                        <logic:notEqual name="customerSelectList" value="null">
                            <option value = <bean:write name="customerSelectList" property="value"/>>
                                <bean:write name="customerSelectList" property="label"/>
                            </option>
                        </logic:notEqual>
                    </logic:iterate>
            </select>
        </td>
        <td width="5%">&nbsp;</td>
        <td width="15%" valign= "top" nowrap="true">
            <font class="NArialL"><bean:message key="label.mfgPartNumber" /> :</font>
        </td>
        <td width="20%"><font class="NArialL" valign= "top">
        <select name="products" class="txfield"  style= "width:170px" multiple="true" size = "5">
            <option value="0" selected>All Products</option>
                <logic:iterate id="mktgPartNumberSelectList" name="mktgPartNumberSelectList">
                    <logic:notEqual name="mktgPartNumberSelectList" value="null">
                        <option value = <bean:write name="mktgPartNumberSelectList" property="productId"/>>
                            <bean:write name="mktgPartNumberSelectList" property="manufacturingPartNo"/>
                        </option>
                    </logic:notEqual>
                </logic:iterate>
            </select>
        </font>
        </td>
    </tr>
    <tr >
        <td width="5%" valign= "top">&nbsp;</td>
        <td width="20%"><font class="NArialL">Region :</font></td>
        <td width="20%" class="NArialL">
            <select name="region" class="txfield" style="width:170px" >
                <option value="0">All Regions</option>
                    <logic:iterate id="regionList" name="regionList">
                        <logic:notEqual name="regionList" value="null">
                            <option value = "<bean:write name="regionList" />">
                                <bean:write name="regionList"/>
                            </option>
                        </logic:notEqual>
                    </logic:iterate>
            </select>
        </td>
        <td width="5%">&nbsp;</td>
        <td width="15%" class="NArialL">Regional Rep :</td>
        <td width="20%"><font class="NArialL">
        <select name="repoffices" class="txfield" style= "width:170px" >
            <option value="0">All Regional Reps</option>
                <logic:iterate id="repOfficeList" name="repOfficeList">
                    <logic:notEqual name="repOfficeList" value="null">
                        <option value = "<bean:write name="repOfficeList" />">
                            <bean:write name="repOfficeList"/>
                        </option>
                    </logic:notEqual>
                </logic:iterate>
            </select>
        </font>
        </td>
    </tr>
    <tr>
        <td width="5%">&nbsp;</td>
        <td width="20%" norap><font class="NArialL"><bean:message key="label.sales.endCustomer"/> : </font></td>
        <td width="20%"><font class="NArialL">
            <select name="endCustomer" class="txfield" style= "width:170px" >
                <option value="0">All <bean:message key="label.sales.endCustomer"/>s</option>
                    <logic:iterate id="endCustomerList" name="endCustomerList">
                        <logic:notEqual name="endCustomerList" value="null">
                            <option value = "<bean:write name="endCustomerList" property="label"/>">
                                <bean:write name="endCustomerList" property="label"/>
                            </option>
                        </logic:notEqual>
                    </logic:iterate>
                </select>
            </font>
        </td>
        <td width="5%">&nbsp;</td>
        <td width="15%"><font class="NArialL">Sales Person :</font></td>
        <td width="20%"><font class="NArialL">
            <select name="sperson" class="txfield" style= "width:170px" >
                <option value="0">All Sales Persons</option>
                    <logic:iterate id="salesPersonList" name="salesPersonList">
                        <logic:notEqual name="salesPersonList" value="null">
                            <option value = "<bean:write name="salesPersonList" />">
                                <bean:write name="salesPersonList"/>
                            </option>
                        </logic:notEqual>
                    </logic:iterate>
                </select>
            </font>
        </td>
    </tr>
    <tr>
        <td width="5%">&nbsp;</td>
        <td width="20%"><font class="NArialL"><bean:message key="label.sales.endUser"/> :</font></td>
        <td width="20%"><font class="NArialL">
            <select name="endUser" class="txfield" style= "width:170px" >
                <option value="0">All <bean:message key="label.sales.endUser"/>s</option>
                    <logic:iterate id="endUserList" name="endUserList">
                        <logic:notEqual name="endUserList" value="null">
                            <option value = "<bean:write name="endUserList" property="label"/>">
                                <bean:write name="endUserList" property="label"/>
                            </option>
                        </logic:notEqual>
                    </logic:iterate>
                </select>
            </font>
        </td>
        <td width="5%">&nbsp;&nbsp;</td>
        <td width="15%"><font class="NArialL">Category :</font></td>
        <td width="20%">
            <select name="orderType" class="txfield" style= "width:170px" >
                <option value="1" selected >Regular</option>
                <option value="0">Sample</option>
                <option value="2">Consignment</option>
            </select>
    </tr>

    <tr>
        <td width="5%">&nbsp;</td>
        <td width="15%"><font class="NArialL">From-Date :</font></td>
        <td width="20%"><font class="NArialL">
                <input type="text" name="fromdate" size="12" class="txfield"></font>
                <a href="javascript:openCalendar(document.salesReport.fromdate)"onmouseover="window.status='Click to Select From Date';return true"onmouseout="window.status='';return true"title="Click here to Select From Date">
                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=18 width=18></a>
	    </td>
        <td width="5%">&nbsp;&nbsp;</td>
        <td width="15%"><font class="NArialL">To-Date :</font></td>
        <td width="20%"><font class="NArialL">
                <input type="text" name="todate" size="12" class="txfield"></font>
                <a href="javascript:openCalendar(document.salesReport.todate)"onmouseover="window.status='Click to Select To Date';return true"onmouseout="window.status='';return true"title="Click here to Select To Date">
                <img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=18 width=18></a>
        </td>
    </tr>
    <tr><td colsapn=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <tr>
            <td width="5%">&nbsp;</td>
            <td colspan=5  norap>
    	  	<input type="radio" name="category" value="bookingReport" checked onclick ="javascript:enableSort()">
    		<font class="NArialL">Booking</font>&nbsp;
    	    <input type="radio" name="category" value="cancellation"  onclick ="javascript:enableSort()">
    		<font class="NArialL">Cancellation</font>&nbsp;
            <input type="radio" name="category" value="hold" onclick ="javascript:enableSort()">
            <font class="NArialL">Hold</font>&nbsp;
            <input type="radio" name="category" value="delinquent" onclick ="javascript:enableSort()">
    		<font class="NArialL">Delinquent Orders</font> &nbsp;
             </td>
    </tr>

    <tr><td colsapn=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <tr>
         <td width="5%">&nbsp;</td>
        <td colspan=5>
            <input type="radio" name="orderBy" value="bookingDate" onclick="javascript:enablePeriod()">
	    		<font class="NArialL">Booking Date </font>&nbsp;&nbsp;&nbsp;&nbsp;
	    	<input type="radio" name="orderBy" value="changeDate" checked onclick="javascript:enablePeriod()">
	    		<font class="NArialL">Change Date </font>&nbsp;&nbsp;&nbsp;&nbsp;
	    	<input type="radio" name="orderBy" value="salesOrder" onclick="javascript:enablePeriod()">
	    		<font class="NArialL">Sales Order Number</font>
        </td>
    </tr>

    <tr><td colsapn=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>
    <tr>
        <td width="5%">&nbsp;</td>
        <td colspan=5>
	    	<input type="radio" name="periodically" value="byWeek" checked>
	    		<font class="NArialL">By Week </font>&nbsp;&nbsp;&nbsp;&nbsp;
	    	<input type="radio" name="periodically" value="byMonth" >
	    		<font class="NArialL">By Month</font>&nbsp;&nbsp;&nbsp;&nbsp;
	    	<input type="radio" name="periodically" value="byQuarter">
	    		<font class="NArialL">By Quarter</font>
        </td>

    </tr>
    <tr>
        <td colspan=6    width="100%" align="right">
        <a class="NArialL" href="javascript:dateRange(3)" onMouseOver="window.status='Click here to Export to CSV';return true" onMouseOut="window.status='';return true" title='Click here to Export to CSV' >Export to CSV</a>
    </td>
    </tr>


    <tr>
      <td colspan=6 align=center><input type="image" onClick="javascript:return dateRange(1);" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Report';return true"onmouseout="window.status='';return true"title="Click here to Generate Report"/>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="javascript:document.salesReport.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"title="Click here to Reset"></a>
    </tr>
    <tr>
        <td width='180' valign='top'>&nbsp;</td> 
        <td colspan=5 align="right" >
            <a class="NArialL" href="javascript:installNPViewer()" onMouseOver="window.status='Click here to install Activex Control for Reports';return true" onMouseOut="window.status='';return true" title='Click here to install Activex Control for Reports' >Click here to install Activex Control for Reports
            </a></td>
        <td colsapn=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=40></td>
    </tr>
  </table>



<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</form>
</BODY>
</HTML>
<%--<% } catch(Exception e){e.printStackTrace();} %>--%>
